(define splitString
  (native_function "
    Proc.new do |arguments, interpreter|
      arg1 = interpreter.evaluate(arguments[0])
      if arg1.is_a? String
        arg1.split
      else
        raise 'splitString function takes a string as an argument.'
      end
    end
  "))

(define split 
  (function (x) 
    (define keys (list))
    (define values (list))
    (if (isA? x (assoc))
      (do 
        (each x k v 
          (define keys (append keys k))
          (define values (append values v))
          (return (assoc (pair (quote keys) keys) (pair (quote values) values)))
        )
      )
      (if (isA? x (list))
        (do 
          (each x element
            (define keys (append keys (index x element)))
            (define values (append values element))
            (return (assoc (pair (quote keys) keys) (pair (quote values) values)))
          )
        )
        (if (isA? x (str))
          (splitString x)
          ()
        )
      )
    )
  )
)
